namespace InfoLogic.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class PRODUCT_TABLE_ADDED1 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Business", "Product_ProductId", "dbo.Product");
            DropIndex("dbo.Business", new[] { "Product_ProductId" });
            CreateTable(
                "dbo.ProductBusinesses",
                c => new
                    {
                        Product_ProductId = c.Guid(nullable: false),
                        Business_BusinessId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => new { t.Product_ProductId, t.Business_BusinessId })
                .ForeignKey("dbo.Product", t => t.Product_ProductId, cascadeDelete: true)
                .ForeignKey("dbo.Business", t => t.Business_BusinessId, cascadeDelete: true)
                .Index(t => t.Product_ProductId)
                .Index(t => t.Business_BusinessId);
            
            DropColumn("dbo.Business", "Product_ProductId");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Business", "Product_ProductId", c => c.Guid());
            DropIndex("dbo.ProductBusinesses", new[] { "Business_BusinessId" });
            DropIndex("dbo.ProductBusinesses", new[] { "Product_ProductId" });
            DropForeignKey("dbo.ProductBusinesses", "Business_BusinessId", "dbo.Business");
            DropForeignKey("dbo.ProductBusinesses", "Product_ProductId", "dbo.Product");
            DropTable("dbo.ProductBusinesses");
            CreateIndex("dbo.Business", "Product_ProductId");
            AddForeignKey("dbo.Business", "Product_ProductId", "dbo.Product", "ProductId");
        }
    }
}
